<!DOCTYPE html>
<html lang="zh-CN">
<head>
<title>编辑病例</title>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="apple-mobile-web-app-status-bar-style" content="black"/>
<meta name="format-detection" content="telephone=no"/>
<meta name="format-detection" content="email=no"/>
<meta name="format-detection" content="address=no"/>
<link href="__PUBLIC__/css/base.css" rel="stylesheet"/>
</head>
<body>
<!---  头部开始  -->
<div class="top clearfix">
	<div class="icon_left"></div>
	<div class="icon_right"></div>
</div>
<!---  头部结束  -->
<div class="fbbl cssss">
	<div class="title_02">病例信息</div>
	<if condition="$level gt 2">
	<div class="box_04 fc_click1" remind="blex">
		<b>病例类型：</b>
		<span class="blex"><if condition="$record.cashtype eq 1">免费<else />收费</if></span>
		<i class="jiantou4"></i>
	</div>		
	</if>
	<div class="box_04 pri none">
		<b>收费费用：</b><em>￥  </em>
		<span class="price">0.00</span>
	</div>
	<div class="box_04 fc_click1" remind="gender">
		<b>患者性别：</b>
		<span class="gender">{$record.gender}</span>
		<i class="jiantou4"></i>
	</div>
	<div class="box_04 fc_click1" remind="age">
		<b>年&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;龄：</b>
		<span class="age">{$age1}</span>
		<i class="jiantou4"></i>
	</div>
	<div class="box_04">
		<b>主&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;诉：</b>
		<span class="complain">{$record.complain}</span>
	</div>
	<div class="box_04" >
		<b>病&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;史：</b>
		<span class="history">{$record.history}</span>
	</div>
	<div class="box_04">
		<b>口腔病史：</b>
		<span class="oralhistory">{$record.oralhistory}</span>
	</div>
	<div class="box_04">
		<b>家庭史和个人基本情况：</b>
		<span class="profile">{$record.profile}</span>
	</div>
	<div class="box_04">
		<b>检&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;查：</b>
		<span class="normalcheck">{$record.normalcheck}</span>
	</div>
	<div class="box_04">
		<b>特殊检查和辅助检查：</b>
		<span class="specialcheck">{$record.specialcheck}</span>
	</div>
	<div class="box_04">
		<b>诊&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;断：</b>
		<span class="diagnostic">{$record.diagnostic}</span>
	</div>
	<div class="box_04 fc_click1" remind="major">
		<b>专业选择：</b>
		<span class="major">{$record.major}</span>
		<i class="jiantou4"></i>
	</div>
	<div class="box_04">
		<b>治疗计划和治疗：</b>
		<span class="tp">{$record.tp}</span>
	</div>
	<div class="box_04">
		<b>复诊和维护治疗：</b>
		<span class="rediagnosis">{$record.rediagnosis}</span>
	</div>
	<div class="box_04">
		<b>预&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;后：</b>
		<span class="prognosis">{$record.prognosis}</span>
	</div>
	<div class="box_04 noClck" remind="images">
		<b>照片上传：</b>
		<span>最多可上传9张</span>
	</div>
	<div class="box_04 photo_list1">
		<volist name="images" id="vo">
			<a><img src="{$vo.image}" /></a>
		</volist>
		<a class="add" id="add"><img src="__PUBLIC__/img/base/add.png" /></a>
	</div>
	<div class="box_04">
		<b>需要讨论与问题：</b>
		<span class="discuss">{$record.discuss}</span>
	</div>
	<div class="bots">
		<a class="save_draft">存草稿</a>
		<a class="publish">发布</a>
	</div>
</div>
<!---  统一样式浮层开始  -->
<div class="fc_box none">
	<div class="fcBox_bg"></div>
	<div class="fcBox_text">
		<dl>
			<dt>选择性别：<span class="close3" onclick="close3(this);"></span></dt>
			<dd>未知</dd>
		</dl>
	</div>
</div>
<!---  统一样式浮层结束  -->
<!---  填写框开始  -->
<div class="text_Box none">
	<div class="textBox_bg"></div>
	<div class="textBox_text">
		<i class="close4"></i>
		<textarea name="" id="" cols="30" rows="10"></textarea>
		<a class="confirm"><span>确定</span></a>
	</div>
</div>
<!---  填写框结束  -->
<!---  图片点击放大开始  -->
<div class="picBox none">
	<div class="picBox_bg"></div>
	<div class="picBox_img">
		<div class="delete_04">删除</div>
		<i class="close2"></i>
		<img src="__PUBLIC__/img/pic/head_02.png" />
	</div>
</div>
<!---  图片点击放大结束  -->
<!---  存草稿 提示框开始  -->
<div class="reminder_box reminder1 none">
	<div class="reminderBox_bg"></div>
	<div class="reminderBox_text">
		<p>亲，您的病例将保存到“个人中心—我的病例—未发布”里，您可以再次编辑后发布此病例。</p>
		<p class="texcen"><a class="iKnow"><span>知道了</span></a></p>
	</div>
</div>
<!---  存草稿 提示框结束  -->
<!---  发布 提示框开始  -->
<div class="reminder_box reminder2 none">
	<div class="reminderBox_bg"></div>
	<div class="reminderBox_text">
		<p>亲，您的病例已发布~</p>
		<p>如需邀请专家点评,请按“邀请专家”进入专家页面，也可在病例页面中邀请专家。</p>
		<a class="confirm2"><span>确定</span></a>
		<a class="invite2"><span>邀请专家</span></a>
	</div>
</div>
<!---  发布 提示框结束  -->
</body>
<script src="__PUBLIC__/js/jquery.js"></script>
<script src="__PUBLIC__/js/comm.js"></script>
<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script type="text/javascript">
var cashtype = {$record.cashtype};//1免费 2收费
$(function(){
	if(cashtype==1){				//1免费
		$(".pri").addClass("none");
	}else if(cashtype==2){		//2收费
		$(".pri").removeClass("none");
	}
});
var gender,
	age,	
	age1,	
	complain,
	historys,
	oralhistory,
	profile,
	normalcheck,
	specialcheck,
	diagnostic,
	major,
	tp,
	rediagnosis,
	prognosis,
	discuss;
wx.config({
    debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
    appId: '{$appid}', // 必填，公众号的唯一标识
    timestamp: {$timestamp} , // 必填，生成签名的时间戳
    nonceStr: '{$nonceStr}', // 必填，生成签名的随机串
    signature: '{$signature}',// 必填，签名，见附录1
    	jsApiList: [
		'uploadImage',
		'chooseImage',
		'checkJsApi',
		'onMenuShareAppMessage',
        'onMenuShareTimeline',
        'onMenuShareQQ',
        'onMenuShareWeibo'
	] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
});
var images = {
	localId: [],
	serverId: []
};
wx.ready(function(){
  	$(".photo_list1 a.add").click(function(){
		wx.chooseImage({
			success: function (res) {
				images.localId = res.localIds;
				//alert(parseInt($(".add_photo li").length+images.localId.length));
				if(parseInt($(".photo_list1 a").length+images.localId.length)>10){
					alert("您添加的照片已经超过9张");
					return false;
				}else{
						var i=0;length=images.localId.length;
						function upload(){
							wx.uploadImage({
								localId: images.localId[i],
								success: function (res) {
										i++;
										alert('已上传：' + i + '/' + length);
										$.post("__URL__/editMedia",{mediaid:res.serverId},function(e){
											//alert(res.serverId);
											//alert(e.image);
											new_element="<a><img src='"+e.image+"' /></a>";
											$(".photo_list1 a:last").before(new_element);
										});
										if (i < length) {
									    	upload();
										}	
									},
								    fail: function (res) {
								    	alert(JSON.stringify(res));
								    }
							});
						}
						upload();	


						
											
				}
				if($(".photo_list1 a").length>9){
					$(".photo_list1 a:last").remove();
				}
			}
		});  		
  	});	
});
wx.error(function(res){
	alert(res.errMsg);
});
function saverecord(pubtype){
	var length = parseInt($(".photo_list1 a[id!='add']").length);
	if(length==0){
		var image=0;
		postresult(pubtype,image);
	}else{
		var sid = [];
		for(var i=0;i<length;i++){
			sid.push($(".photo_list1 a:eq("+i+")").find("img").attr("src"));
		}
		var image=sid.join(',');
		//alert(image);
		postresult(pubtype,image);	
	}
}
function postresult(pubtype,image){	
	$.post('__URL__/bl_edit',{
		id:{$record.id},
		pubtype:pubtype,
		gender:gender,
		age:age,
		major:major,
		complain:complain,
		history:historys,
		oralhistory:oralhistory,
		profile:profile,
		normalcheck:normalcheck,
		specialcheck:specialcheck,
		diagnostic:diagnostic,
		tp:tp,
		rediagnosis:rediagnosis,
		prognosis:prognosis,
		discuss:discuss,
		images:image,
	},function(e){
		if(e.status==1){
			if(pubtype==1){			//存草稿
				$(".reminder1").removeClass("none");
			}
			if(pubtype==2){			//发布
				$(".reminder2").removeClass("none");
			}
		}
	});		
}
var remind;
$(".photo_list1 a[id!=add]").live("click",function(){
	$(".picBox").removeClass("none");
	$(".picBox img").attr("src",$(this).find("img").attr("src"));	
	$(".picBox .delete_04").attr("inId",$(this).index());
});
$(".delete_04").click(function(){
	$(".picBox").addClass("none");
	$(".photo_list1 a:eq("+$(this).attr("inId")+")").remove();
});
//选择下拉
$(".fc_click1").click(function(){
	remind=$(this).attr("remind");
	var html;
	if(remind=="blex"){
		html='<dl alt="'+remind+'">'+
			'<dt>选择病例类型：<span class="close3" onclick="close3(this);"></span></dt>'+
			'<dd onclick="ddValue(this)">免费</dd>'+
			'<dd onclick="ddValue(this)">收费</dd>'+
		'</dl>';
	}else if(remind=="gender"){
		html='<dl alt="'+remind+'">'+
			'<dt>选择性别：<span class="close3" onclick="close3(this);"></span></dt>'+
			'<dd onclick="ddValue(this)">未知</dd>'+
			'<dd onclick="ddValue(this)">男</dd>'+
			'<dd onclick="ddValue(this)">女</dd>'+
		'</dl>';
	}else if(remind=="age"){
		html='<dl alt="'+remind+'">'+
			'<dt>选择年龄：<span class="close3" onclick="close3(this);"></span></dt>'+
			<volist name="age" id="vo">
			'<dd onclick="ddValue(this)" age="{$vo.id}">{$vo.age}</dd>'+
			</volist>
		'</dl>';
	}else if(remind=="major"){
		html='<dl alt="'+remind+'">'+
			'<dt>选择专业：<span class="close3" onclick="close3(this);"></span></dt>'+
			<volist name="major" id="vo">
			'<dd onclick="ddValue(this)">{$vo.name}</dd>'+
			</volist>
		'</dl>';		
	}
	$(".fcBox_text").html(html);
	$(".fc_box").removeClass("none");
});
//点击浮层选项
function ddValue(name1){	
	if($(name1).html()=="收费"){
		cashtype=2;
		$(".pri").removeClass("none");
	}else if($(name1).html()=="免费"){
		cashtype=1;
		$(".pri").addClass("none");
	}
	if($(name1).attr("age")==undefined){
		age="";
	}else{
		age=$(name1).attr("age");
	}
	if(age.length>0){
		$(".fc_click1").find("."+$(name1).parents("dl").attr("alt")).attr("tjage",age);
	}
	$(name1).parents(".fc_box").addClass("none");
	$(".fc_click1").find("."+$(name1).parents("dl").attr("alt")).html($(name1).html());
}
//点击选项  填写
$(".box_04").not(".fc_click1,.photo_list1,.noClck").click(function(){
	$(".text_Box textarea").val("");
	remind=$(this).find("span").attr("class");
	$(".text_Box").attr("re",remind).removeClass("none");	
});
//关闭输入框
$(".close4").click(function(){
	$(this).parents(".text_Box").find("textarea").html("");
	$(this).parents(".text_Box").addClass("none");
});
//确定
$(".confirm").click(function(){
	remind=$(this).parents(".text_Box").attr("re");
	$(".box_04").find("."+remind).html($(".text_Box textarea").val());

	$(this).parents(".text_Box").addClass("none");
});
//存草稿
$(".save_draft").click(function(){	
	if(check()!=false){
		saverecord("1");
	}	
});
//存草稿 我知道了
$(".iKnow").click(function(){
	$(".reminder1").removeClass("none");
	window.location.href="__URL__";
});
//发布
$(".publish").click(function(){
	if(check()!=false){
		saverecord("2");
	}	
});
//发布 确定
$(".confirm2").click(function(){
	$(".reminder2").addClass("none");
});
//发布 邀请专家
$(".invite2").click(function(){
	$(".reminder2").addClass("none");
	window.location.href="__URL__/yqzj";
});

function check(){
	price=$.trim($(".fbbl span.price").html());
	gender=$.trim($(".fbbl span.gender").html());
	age1=$.trim($(".fbbl span.age").html());
	complain=$.trim($(".fbbl span.complain").html());
	historys=$.trim($(".fbbl span.history").html());
	oralhistory=$.trim($(".fbbl span.oralhistory").html());
	profile=$.trim($(".fbbl span.profile").html());
	normalcheck=$.trim($(".fbbl span.normalcheck").html());
	specialcheck=$.trim($(".fbbl span.specialcheck").html());
	diagnostic=$.trim($(".fbbl span.diagnostic").html());
	major=$.trim($(".fbbl span.major").html());
	tp=$.trim($(".fbbl span.tp").html());
	rediagnosis=$.trim($(".fbbl span.rediagnosis").html());
	prognosis=$.trim($(".fbbl span.prognosis").html());
	discuss=$.trim($(".fbbl span.discuss").html());
	//images=$.trim($(".fbbl .images").html());
	if(cashtype==2){
		if(price.length<1 || parseInt(price)==0){
			alert("请正确填写收费使用");
			return false;
		}
	}else{
		price=0;
	}	
	if(gender.length<1){
		alert("请选择性别");
		return false;
	}
	if(age1.length<1){
		alert("请选择年龄");
		return false;
	}
	age=$(".age").attr("tjage");
	if(complain.length<1 || complain=="用简洁，用患者的语言描述"){
		complain="无";
	}
	if(history.length<1 || history=="包含现病史与既往史，全身健康状况和慢性病史、用药和治疗情况等"){
		history="无";
	}
	if(oralhistory.length<1 || oralhistory=="口腔科就诊史，口腔清洁护理状况"){
		oralhistory="无";
	}
	if(profile.length<1 || profile=="吸烟，饮酒史"){
		profile="无";
	}
	if(normalcheck.length<1 || normalcheck=="（* 必填）口外和口内情况" ){
		alert("请输入检查");
		return false;
	}
	if(specialcheck.length<1 || specialcheck=="如X线检查，曲面断层，根尖片，咬合翼片，CT等"){
		specialcheck="无";
	}
	if(diagnostic.length<1 || diagnostic=="（* 必填）"){
		alert("请输入诊断");
		return false;
	}
	if(major.length<1 || major=="（* 必填）牙周"){
		alert("请选择专业");
		return false;
	}
	if(tp.length<1 || tp=="（* 必填）"){
		alert("请输入治疗计划和治疗");
		return false;
	}
	if(rediagnosis.length<1 || rediagnosis=="（* 必填）"){
		rediagnosis="无";
	}	
	if(prognosis.length<1 || prognosis=="（* 必填）"){
		prognosis="无";
	}
	if(discuss.length<1 || discuss=="（* 必填）"){
		discuss="无";
	}
}
</script>
</html>